/**
 * Created by alickgeng on 2016/11/22.
 */

function getLinks() {
    var links = document.querySelectorAll('h3.r a');
    return Array.prototype.map.call(links, function (e) {
        return e.getAttribute('href');
    });
}
function getRepopath() {
    var links = document.getElementsByName('repositoryPath');
    this.echo(links.length + ' links found:');
    return links[0].getElementsByTagName("a")[0].getAttribute('href');

}

var path = [];
var casper = require('casper').create();
casper.options.waitTimeout = 60 * 1000
casper.start('http://nexus.oa.yitopapp.com/#nexus-search;quick~cxy', function () {
    this.waitForText("Repository");
});

casper.then(function () {
    path = this.evaluate(getLinks);
})

casper.run(function () {
    this.echo(path.length + ' links found:');
    this.echo(' - ' + path.join('\n - ')).exit();
});
